/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package eu.fsiebert.polytech.db.mediatheque.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

/**
 *
 * @author Florent
 */
@Entity
@Table(name = "TypeItem")
@NamedQueries({
    @NamedQuery(name = "TypeItem.findAll", query = "SELECT t FROM TypeItem t"),
    @NamedQuery(name = "TypeItem.findByNomType", query = "SELECT t FROM TypeItem t WHERE t.nomType = :nomType"),
    @NamedQuery(name = "TypeItem.findByDureeEmprunt", query = "SELECT t FROM TypeItem t WHERE t.dureeEmprunt = :dureeEmprunt"),
    @NamedQuery(name = "TypeItem.findByNbRenouvellement", query = "SELECT t FROM TypeItem t WHERE t.nbRenouvellement = :nbRenouvellement"),
    @NamedQuery(name = "TypeItem.findByNbMaxEmprunt", query = "SELECT t FROM TypeItem t WHERE t.nbMaxEmprunt = :nbMaxEmprunt")})
public class TypeItem implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "NomType", nullable = false)
    private Integer nomType;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DureeEmprunt", nullable = false)
    private int dureeEmprunt;
    @Basic(optional = false)
    @NotNull
    @Column(name = "NbRenouvellement", nullable = false)
    private int nbRenouvellement;
    @Basic(optional = false)
    @NotNull
    @Column(name = "NbMaxEmprunt", nullable = false)
    private int nbMaxEmprunt;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "nomType")
    private List<Item> itemList;

    public TypeItem() {
    }

    public TypeItem(Integer nomType) {
        this.nomType = nomType;
    }

    public TypeItem(Integer nomType, int dureeEmprunt, int nbRenouvellement, int nbMaxEmprunt) {
        this.nomType = nomType;
        this.dureeEmprunt = dureeEmprunt;
        this.nbRenouvellement = nbRenouvellement;
        this.nbMaxEmprunt = nbMaxEmprunt;
    }

    public Integer getNomType() {
        return nomType;
    }

    public void setNomType(Integer nomType) {
        this.nomType = nomType;
    }

    public int getDureeEmprunt() {
        return dureeEmprunt;
    }

    public void setDureeEmprunt(int dureeEmprunt) {
        this.dureeEmprunt = dureeEmprunt;
    }

    public int getNbRenouvellement() {
        return nbRenouvellement;
    }

    public void setNbRenouvellement(int nbRenouvellement) {
        this.nbRenouvellement = nbRenouvellement;
    }

    public int getNbMaxEmprunt() {
        return nbMaxEmprunt;
    }

    public void setNbMaxEmprunt(int nbMaxEmprunt) {
        this.nbMaxEmprunt = nbMaxEmprunt;
    }

    public List<Item> getItemList() {
        return itemList;
    }

    public void setItemList(List<Item> itemList) {
        this.itemList = itemList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (nomType != null ? nomType.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TypeItem)) {
            return false;
        }
        TypeItem other = (TypeItem) object;
        if ((this.nomType == null && other.nomType != null) || (this.nomType != null && !this.nomType.equals(other.nomType))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "eu.fsiebert.polytech.db.mediatheque.entity.TypeItem[ nomType=" + nomType + " ]";
    }
    
}
